package com.juc.threadPoolExecutor.threadPoolExecutor14;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class LinkedBlockingDequeTest2 {
	    //LinkedBlockingDeque使用带参构造
		//max值被参考
	    //但队列容量不够，有一个任务出现异常
		public static void main(String[] args) {
			LinkedBlockingDeque<Runnable> linked = new LinkedBlockingDeque<Runnable>(2);
			System.out.println(linked.size());
			ThreadPoolExecutor executor = new ThreadPoolExecutor(2, 3, 5, TimeUnit.SECONDS, linked);
			executor.execute(new MyRunnable());
			executor.execute(new MyRunnable());
			executor.execute(new MyRunnable());
			executor.execute(new MyRunnable());
			executor.execute(new MyRunnable());
			executor.execute(new MyRunnable());
			System.out.println(executor.getPoolSize() + "     " + linked.size());
			//放入队列2个任务    执行3个任务
			//有1个任务被拒绝
			//有一个任务被拒绝执行，其他任务正常执行
		}
}
